#!/bin/bash
#
# Copyright (C) 2013-2021 Spring Studio
# Copyright (C) 2013-2021 Dou Dongchun <doudongchun@163.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

########### library variables ##########
URI=
GIT=https://gitee.com/springstudio/zlib.git
COMMIT=
LOCAL=zlib

########### build library ##########

build_arch()
{
  # fix undefined symbol: fopen64 ftello64 fseeko64
  sed -i "s/#if defined(USE_FILE32API)/#if (__ANDROID_API__ < 24 || defined(USE_FILE32API))/g" contrib/minizip/ioapi.h

  cd contrib/minizip

  aclocal
  libtoolize --force
  automake --add-missing
  autoconf
  # autoheader

  rm -rf build
  mkdir build
  cd build

  ../configure \
    --prefix=$PREFIX \
    --host=$TARGET \
    --with-sysroot=$SYSROOT \
    --with-pic=yes \
    --enable-shared=no

  make clean
  make -j4 -s
  make install

  cd -
  cd ../..
}

clear_arch() {
  if [ -d build ]; then
    cd build && make clean && cd -
    rm -rf build
  fi
}

############# forbid modify ###########

. ./tools/do-compile.sh
